/**
 * Grid system
 * - 12列网格，基于浮动布局；相对定位实现 push / pull
 * - Mobile first
 * - Breakpoint:
 *        sm:    <= 640px
 *        md:   641px <= 1024px
 *        lg:    >1024px
 */


// Mixins
// ========================================================================

.col-reset-order() {
  margin-left: 0;
  margin-right: 0;
  left: auto;
  right: auto;
  float: left;
}


.am-g {
  margin: 0 auto;
  width: 100%;
  .clearfix();
  &.am-g-collapse {
    .am-col, [class*='col-'] {
      padding-left: 0;
      padding-right: 0;
    }
  }

  // grid nested
  .am-g {
    margin-left: -@grid-gutter-width;
    margin-right: -@grid-gutter-width;
    width: auto;
    &.am-g-collapse {
      margin-left: 0;
      margin-right: 0;
    }
  }
}


/* Fixed Grid */

.am-g-fixed {
  max-width: @grid-max-width;
}


.am-col, [class^='col-'] {
  width: 100%;
  padding-left: @grid-gutter-width;
  padding-right: @grid-gutter-width;
  float: left;
  position: relative;
}

/* Increasing gutter for medium and large screen */

@media @medium-up {
  .am-g .am-g {
    margin-left: -@grid-gutter-md-width;
    margin-right: -@grid-gutter-md-width;
  }

  .am-col, [class*='col-'] {
    padding-left: @grid-gutter-md-width;
    padding-right: @grid-gutter-md-width;
  }
}

@media @screen {
  .col-sm-1 {
    width: 8.33333%;
  }

  .col-sm-2 {
    width: 16.66667%;
  }

  .col-sm-3 {
    width: 25%;
  }

  .col-sm-4 {
    width: 33.33333%;
  }

  .col-sm-5 {
    width: 41.66667%;
  }

  .col-sm-6 {
    width: 50%;
  }

  .col-sm-7 {
    width: 58.33333%;
  }

  .col-sm-8 {
    width: 66.66667%;
  }

  .col-sm-9 {
    width: 75%;
  }

  .col-sm-10 {
    width: 83.33333%;
  }

  .col-sm-11 {
    width: 91.66667%;
  }

  .col-sm-12 {
    width: 100%;
  }

  .col-sm-offset-0 {
    margin-left: 0%;
  }

  .col-sm-offset-1 {
    margin-left: 8.33333%;
  }

  .col-sm-offset-2 {
    margin-left: 16.66667%;
  }

  .col-sm-offset-3 {
    margin-left: 25%;
  }

  .col-sm-offset-4 {
    margin-left: 33.33333%;
  }

  .col-sm-offset-5 {
    margin-left: 41.66667%;
  }

  .col-sm-offset-6 {
    margin-left: 50%;
  }

  .col-sm-offset-7 {
    margin-left: 58.33333%;
  }

  .col-sm-offset-8 {
    margin-left: 66.66667%;
  }

  .col-sm-offset-9 {
    margin-left: 75%;
  }

  .col-sm-offset-10 {
    margin-left: 83.33333%;
  }

  .col-sm-offset-11 {
    margin-left: 91.66667%;
  }

  .col-sm-push-0 {
    position: relative;
    left: 0%;
    right: auto;
  }

  .col-sm-pull-0 {
    right: 0%;
    left: auto;
  }

  .col-sm-push-1 {
    left: 8.33333%;
    right: auto;
  }

  .col-sm-pull-1 {
    right: 8.33333%;
    left: auto;
  }

  .col-sm-push-2 {
    left: 16.66667%;
    right: auto;
  }

  .col-sm-pull-2 {
    right: 16.66667%;
    left: auto;
  }

  .col-sm-push-3 {
    left: 25%;
    right: auto;
  }

  .col-sm-pull-3 {
    right: 25%;
    left: auto;
  }

  .col-sm-push-4 {
    left: 33.33333%;
    right: auto;
  }

  .col-sm-pull-4 {
    right: 33.33333%;
    left: auto;
  }

  .col-sm-push-5 {
    left: 41.66667%;
    right: auto;
  }

  .col-sm-pull-5 {
    right: 41.66667%;
    left: auto;
  }

  .col-sm-push-6 {
    left: 50%;
    right: auto;
  }

  .col-sm-pull-6 {
    right: 50%;
    left: auto;
  }

  .col-sm-push-7 {
    left: 58.33333%;
    right: auto;
  }

  .col-sm-pull-7 {
    right: 58.33333%;
    left: auto;
  }

  .col-sm-push-8 {
    left: 66.66667%;
    right: auto;
  }

  .col-sm-pull-8 {
    right: 66.66667%;
    left: auto;
  }

  .col-sm-push-9 {
    left: 75%;
    right: auto;
  }

  .col-sm-pull-9 {
    right: 75%;
    left: auto;
  }

  .col-sm-push-10 {
    left: 83.33333%;
    right: auto;
  }

  .col-sm-pull-10 {
    right: 83.33333%;
    left: auto;
  }

  .col-sm-push-11 {
    left: 91.66667%;
    right: auto;
  }

  .col-sm-pull-11 {
    right: 91.66667%;
    left: auto;
  }

  .col-sm-reset-order {
    .col-reset-order();
  }

  [class='am-col'] + [class='am-col']:last-child,
  [class^='col-'] + [class^='col-']:last-child {
    float: right;
  }

  [class='am-col'] + [class='am-col'].col-end,
  [class^='col-'] + [class^='col-'].col-end {
    float: left;
  }

  .am-col.col-sm-centered,
  [class^='col-'].col-sm-centered {
    margin-left: auto;
    margin-right: auto;
    float: none;

    &:last-child {
      float: none;
    }
  }

  .am-col.col-sm-uncentered,
  [class^='col-'].col-sm-uncentered {
    margin-left: 0;
    margin-right: 0;
    float: left;

    &:last-child {
      float: left;
    }
  }
}

@media @medium-up {
  .col-md-1 {
    width: 8.33333%;
  }

  .col-md-2 {
    width: 16.66667%;
  }

  .col-md-3 {
    width: 25%;
  }

  .col-md-4 {
    width: 33.33333%;
  }

  .col-md-5 {
    width: 41.66667%;
  }

  .col-md-6 {
    width: 50%;
  }

  .col-md-7 {
    width: 58.33333%;
  }

  .col-md-8 {
    width: 66.66667%;
  }

  .col-md-9 {
    width: 75%;
  }

  .col-md-10 {
    width: 83.33333%;
  }

  .col-md-11 {
    width: 91.66667%;
  }

  .col-md-12 {
    width: 100%;
  }

  .col-md-offset-0 {
    margin-left: 0%;
  }

  .col-md-offset-1 {
    margin-left: 8.33333%;
  }

  .col-md-offset-2 {
    margin-left: 16.66667%;
  }

  .col-md-offset-3 {
    margin-left: 25%;
  }

  .col-md-offset-4 {
    margin-left: 33.33333%;
  }

  .col-md-offset-5 {
    margin-left: 41.66667%;
  }

  .col-md-offset-6 {
    margin-left: 50%;
  }

  .col-md-offset-7 {
    margin-left: 58.33333%;
  }

  .col-md-offset-8 {
    margin-left: 66.66667%;
  }

  .col-md-offset-9 {
    margin-left: 75%;
  }

  .col-md-offset-10 {
    margin-left: 83.33333%;
  }

  .col-md-offset-11 {
    margin-left: 91.66667%;
  }

  .col-md-push-1 {
    left: 8.33333%;
    right: auto;
  }

  .col-md-pull-1 {
    right: 8.33333%;
    left: auto;
  }

  .col-md-push-2 {
    left: 16.66667%;
    right: auto;
  }

  .col-md-pull-2 {
    right: 16.66667%;
    left: auto;
  }

  .col-md-push-3 {
    left: 25%;
    right: auto;
  }

  .col-md-pull-3 {
    right: 25%;
    left: auto;
  }

  .col-md-push-4 {
    left: 33.33333%;
    right: auto;
  }

  .col-md-pull-4 {
    right: 33.33333%;
    left: auto;
  }

  .col-md-push-5 {
    left: 41.66667%;
    right: auto;
  }

  .col-md-pull-5 {
    right: 41.66667%;
    left: auto;
  }

  .col-md-push-6 {
    left: 50%;
    right: auto;
  }

  .col-md-pull-6 {
    right: 50%;
    left: auto;
  }

  .col-md-push-7 {
    left: 58.33333%;
    right: auto;
  }

  .col-md-pull-7 {
    right: 58.33333%;
    left: auto;
  }

  .col-md-push-8 {
    left: 66.66667%;
    right: auto;
  }

  .col-md-pull-8 {
    right: 66.66667%;
    left: auto;
  }

  .col-md-push-9 {
    left: 75%;
    right: auto;
  }

  .col-md-pull-9 {
    right: 75%;
    left: auto;
  }

  .col-md-push-10 {
    left: 83.33333%;
    right: auto;
  }

  .col-md-pull-10 {
    right: 83.33333%;
    left: auto;
  }

  .col-md-push-11 {
    left: 91.66667%;
    right: auto;
  }

  .col-md-pull-11 {
    right: 91.66667%;
    left: auto;
  }

  .col-md-reset-order {
    .col-reset-order();
  }

  .am-col.col-md-centered,
  [class^='col-'].col-md-centered {
    margin-left: auto;
    margin-right: auto;
    float: none !important;

    &:last-child {
      float: none !important;
    }
  }

  .am-col.col-md-uncentered,
  [class^='col-'].col-md-uncentered {
    margin-left: 0;
    margin-right: 0;
    float: left !important;

    &:last-child {
      float: left !important;
    }
  }
}

@media @large-up {
  .col-lg-1 {
    width: 8.33333%;
  }

  .col-lg-2 {
    width: 16.66667%;
  }

  .col-lg-3 {
    width: 25%;
  }

  .col-lg-4 {
    width: 33.33333%;
  }

  .col-lg-5 {
    width: 41.66667%;
  }

  .col-lg-6 {
    width: 50%;
  }

  .col-lg-7 {
    width: 58.33333%;
  }

  .col-lg-8 {
    width: 66.66667%;
  }

  .col-lg-9 {
    width: 75%;
  }

  .col-lg-10 {
    width: 83.33333%;
  }

  .col-lg-11 {
    width: 91.66667%;
  }

  .col-lg-12 {
    width: 100%;
  }

  .col-lg-offset-0 {
    margin-left: 0%;
  }

  .col-lg-offset-1 {
    margin-left: 8.33333%;
  }

  .col-lg-offset-2 {
    margin-left: 16.66667%;
  }

  .col-lg-offset-3 {
    margin-left: 25%;
  }

  .col-lg-offset-4 {
    margin-left: 33.33333%;
  }

  .col-lg-offset-5 {
    margin-left: 41.66667%;
  }

  .col-lg-offset-6 {
    margin-left: 50%;
  }

  .col-lg-offset-7 {
    margin-left: 58.33333%;
  }

  .col-lg-offset-8 {
    margin-left: 66.66667%;
  }

  .col-lg-offset-9 {
    margin-left: 75%;
  }

  .col-lg-offset-10 {
    margin-left: 83.33333%;
  }

  .col-lg-offset-11 {
    margin-left: 91.66667%;
  }

  .col-lg-push-1 {
    left: 8.33333%;
    right: auto;
  }

  .col-lg-pull-1 {
    right: 8.33333%;
    left: auto;
  }

  .col-lg-push-2 {
    left: 16.66667%;
    right: auto;
  }

  .col-lg-pull-2 {
    right: 16.66667%;
    left: auto;
  }

  .col-lg-push-3 {
    left: 25%;
    right: auto;
  }

  .col-lg-pull-3 {
    right: 25%;
    left: auto;
  }

  .col-lg-push-4 {
    left: 33.33333%;
    right: auto;
  }

  .col-lg-pull-4 {
    right: 33.33333%;
    left: auto;
  }

  .col-lg-push-5 {
    left: 41.66667%;
    right: auto;
  }

  .col-lg-pull-5 {
    right: 41.66667%;
    left: auto;
  }

  .col-lg-push-6 {
    left: 50%;
    right: auto;
  }

  .col-lg-pull-6 {
    right: 50%;
    left: auto;
  }

  .col-lg-push-7 {
    left: 58.33333%;
    right: auto;
  }

  .col-lg-pull-7 {
    right: 58.33333%;
    left: auto;
  }

  .col-lg-push-8 {
    left: 66.66667%;
    right: auto;
  }

  .col-lg-pull-8 {
    right: 66.66667%;
    left: auto;
  }

  .col-lg-push-9 {
    left: 75%;
    right: auto;
  }

  .col-lg-pull-9 {
    right: 75%;
    left: auto;
  }

  .col-lg-push-10 {
    left: 83.33333%;
    right: auto;
  }

  .col-lg-pull-10 {
    right: 83.33333%;
    left: auto;
  }

  .col-lg-push-11 {
    left: 91.66667%;
    right: auto;
  }

  .col-lg-pull-11 {
    right: 91.66667%;
    left: auto;
  }

  .col-lg-reset-order {
    .col-reset-order();
  }

  .am-col.col-lg-centered,
  [class^='col-'].col-lg-centered {
    margin-left: auto;
    margin-right: auto;
    float: none !important;

    &:last-child {
      float: none !important;
    }
  }

  .am-col.col-lg-uncentered,
  [class^='col-'].col-lg-uncentered {
    margin-left: 0;
    margin-right: 0;
    float: left !important;

    &:last-child {
      float: left !important;
    }
  }
}

// TODO: mixin